package cn.phub.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMVCConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 添加自定义的拦截器到SpringMVC拦截器链
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)//配置拦截器
                .addPathPatterns("/**")//拦截器要拦截的资源--所有
                .excludePathPatterns("/login/**")//放行
                .excludePathPatterns("/shop/settlement")
                .excludePathPatterns("/user/register/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/swagger-resources/**","/webjars/**","/v2/**","/swagger-ui.html/**")
                .excludePathPatterns("/fastDfs/**");

    }
}
